﻿using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI;


namespace AdventureWorks.DashboardGroep6.Content {
    public partial class login : System.Web.UI.Page
    {
        private securityService.Service1 securityService = new securityService.Service1();
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Session["loggedin"].Equals(true))
                {
                    Response.Redirect("/content/menu.aspx");
                }

            }
            catch
            {
            }
        }

        protected void login_btn_Click(object sender, EventArgs e)
        {
            string username = username_box.Text;
            string password = password_box.Text;

            if (securityService.checkLogin(username, password))
            {
                Session["loggedin"] = true;
                String[] roles = securityService.getUserRole(username);
                menu generateMenu = new menu();
                generateMenu.setButtons(roles);
                Response.Redirect("/content/menu.aspx");

            }

        }
    }

}
